<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    
    <!-- 2-1.导入css -->
    <link rel="stylesheet" href="../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../layuiadmin/style/admin.css" media="all">
</head>
<body>
	<div id="headerpage" style="width:100%;height:154px;">
	<!--这个div是为了引入header.html头部-->
    </div> 
    <h2 align="center">修改密码</h2>
    <hr style="height:2px;border:none;background:#003399;"/>
    <form class="layui-form" id="updatePasswd_form" action="">
    <div style="margin:0 auto;width:300px;height:220px;">
    	<div class="layui-form-item">
		    <label class="layui-form-label" style="padding-right:0px;">原密码：</label>
		    <div class="layui-input-inline">
		      <input type="password" id="usepassword" name="passwd" required lay-verify="required" placeholder="请输入原密码" autocomplete="off" class="layui-input">
		    </div>
		 </div>
    	 <div class="layui-form-item">
		    <label class="layui-form-label" style="padding:9px 0px;">新密码：</label>
		    <div class="layui-input-inline">
		      <input type="password" id="newPassword" name="newPasswd" required lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
		    </div>
		 </div>       
  		<div class="layui-form-item">
		    <label class="layui-form-label" style="padding:9px 0px;">确认密码：</label>
		    <div class="layui-input-inline">
		      <input type="password" id="confirmPassword" name="confirmPasswd" required lay-verify="required" placeholder="请输入确认密码" autocomplete="off" class="layui-input">
		    </div>
		 </div> 
		 <div class="layui-form-item">
		    <div class="layui-input-block" style="margin:0 auto;text-align:center">
		      <button class="layui-btn layui-btn-fluid" onclick="return false" style="width:130px;" lay-submit="" lay-filter="LAY-user-reg-submit">修改</button>
		    </div>
  		</div>    
    </div>
    </form>
    <iframe id="footerWrap"  width="100%" height="80px"  scrolling="no" frameborder="0"  src="/footer" noresize="noresize" style="margin-top:100px;"/></iframe>
</body>

<!-- 2-2.导入js -->

<script src="../layuiadmin/layui/layui.js"></script>  
<script>
  
  layui.config({
    base: '../layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form','table', 'laydate'], function(){
    var table = layui.table
    ,form = layui.form
    ,$ = layui.$
    ,admin = layui.admin;
    $("#headerpage").load("/header");
    form.on('submit(LAY-user-reg-submit)', function(data){
       var formData = new FormData(document.getElementById("updatePasswd_form"));
     $.ajax({
	      url: '/user/modifyPasswd',
	      type: 'POST',
	  	  data:formData,
	  	  processData:false,
      	  contentType:false,
	      success: function (data) {
		  if(data==1){
              layer.msg('修改密码成功', {
                  offset: '15px'
                  ,icon: 6
                  ,time: 1000
              });
			}else if(data==2){
              layer.msg('新密码与确认密码不一致',{
                  offset: '15px'
                  ,icon: 2
                  ,time: 1000
              });
			}else if(data==0){
				layer.msg('原密码输入错误',{
                  offset: '15px'
                  ,icon: 2
                  ,time: 1000
              });
			}
		
	       }
}) 
    })
  });
  </script>
</html>